var api = require("./../../../../source/js/service.js");
avalon.component('ms-home-notices',{
	template:require("./notices.html"),
	defaults:{
		lastest:{},
		notices:[],
		bannerHeight:'',
		getNotices:function(){
			var that = this
			return api.getItems({
				method:api.getNotices,
				query:{
					PageSize:6
				}
			},function(res){
				if(res.success){
					avalon.log(res,3333)
					if(res.data.list.length>0){
						that.lastest = res.data.list[0]
						if(res.data.list.length>1){
							that.notices = res.data.list
							that.notices = that.notices.slice(1)
						}
					}
				}
			})
		},
		onInit:function(){
			var that = this;
			return new Promise(function(res,rej){
				res()
			}).then(function(){
				return that.getNotices()
			}).then(function(){
				
				that.bannerHeight = $('.banner').find('img').width()/3
			})
			
		},
		onReady:function(){
			var that = this
			$(window).on('resize',function(event) {
				that.bannerHeight = $('.banner').find('img').width()/3
				event.preventDefault();
				
			});
		}
	}

})